import time
from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get('https://news.baidu.com')
driver.maximize_window()
time.sleep(2)
taglist = driver.find_elements(By.PARTIAL_LINK_TEXT,'科技')
for i in taglist:
    print(i.get_attribute('outerHTML'))


# js1 = 'window.scrollTo(0,document.body.scrollHeight)'
# js2 = 'window.scrollTo(0,0)'
# driver.execute_script(js1)
# time.sleep(1)
# driver.execute_script(js1)
# time.sleep(1)
# driver.execute_script(js1)
# time.sleep(1)
# driver.execute_script('alert("到底部了拉")')
# alter = driver.switch_to.alert
# time.sleep(2)
# alter.dismiss()
# driver.execute_script(js2)
# time.sleep(1)
# driver.execute_script("alert('你干嘛~')")
# alter2 = driver.switch_to.alert
# time.sleep(2)
# alter.accept()
# driver.execute_script(js1)
# time.sleep(1)
# driver.execute_script(js1)
# time.sleep(1)



